package com.touch.client.forms;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLJPanel;
import javax.swing.JFrame;
import com.sun.opengl.util.Animator;
import com.touch.jgloo.JGLFPSLock;
import com.touch.jgloo.JGLOrthoView;
import com.touch.jgloo.core.JGLTextType;
import com.touch.jgloo.owt.JGLComponent;
public class MainPanel extends JFrame
{
	private static final long serialVersionUID = 4176989824218220519L;

	public MainPanel(boolean useJPanel)
	{
		GLAutoDrawable canvas;
		if(useJPanel)
		{
			canvas = new GLJPanel();
			this.add((GLJPanel)canvas);
		}
		else
		{
			canvas = new GLCanvas();
			this.add((GLCanvas)canvas);
		}
				
		JGLComponent.TEXT_TYPE = JGLTextType.STROKE;			
		canvas.addGLEventListener(new JGLOrthoView());
		canvas.addGLEventListener(MainMenuControls.Main_Menu_Events);
		canvas.addGLEventListener(MainMenuControls.Char_Select_Events);
		canvas.addGLEventListener(MainMenuControls.Login_Events);		
		canvas.addGLEventListener(MainMenuControls.New_Account_Events);
		canvas.addGLEventListener(MainMenuControls.New_Character_Events);
		canvas.addGLEventListener(new JGLFPSLock());
		
		canvas.addMouseListener(MainMenuControls.Main_Menu_Events);
		canvas.addMouseListener(MainMenuControls.Char_Select_Events);
		canvas.addMouseListener(MainMenuControls.Login_Events);
		canvas.addMouseListener(MainMenuControls.New_Account_Events);
		canvas.addMouseListener(MainMenuControls.New_Character_Events);
		
		canvas.addKeyListener(MainMenuControls.Login_Events);
		canvas.addKeyListener(MainMenuControls.New_Account_Events);
		canvas.addKeyListener(MainMenuControls.New_Character_Events);
		
		new Animator(canvas).start();
	}
}